//
//  testVC.m
//  UIScrollView的快速使用
//
//  Created by hongfei tam on 2019/2/28.
//  Copyright © 2019 YQ05. All rights reserved.
//

#import "testVC.h"
#import "MKConstant.h"

#import "promotion/promotionTVCtest.h"

#import "registerVC.h"

#import "notitestVC.h"
#import "notitestVC2.h"

#import "network.h"

#import "UIScrollView的快速使用-Swift.h"

@interface testVC (){
    promotionTVCtest *testVC1;
    registerVC *testVC2;
}

@end

@implementation testVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self linshiBTNView];
//    [self cuturl];
}
- (void)linshiBTNView {  //首页临时按钮
    
    
    UIButton *testBtn1 = [[UIButton alloc]initWithFrame:CGRectMake(20, UISCREEN_HEIGHT - 50, 100, 30)];    testBtn1.backgroundColor = [UIColor lightGrayColor];
    [testBtn1 setTitle:@"本地通知" forState:UIControlStateNormal];
    [testBtn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [testBtn1 addTarget:self action:@selector(testAction1) forControlEvents:UIControlEventTouchUpInside];
    testBtn1.layer.borderWidth = 1.0;
    testBtn1.layer.cornerRadius = 3.0;
    [self.view addSubview:testBtn1];
    
    
    UIButton *testBtn2 = [[UIButton alloc]initWithFrame:CGRectMake(140, UISCREEN_HEIGHT - 50, 100, 30)];
    testBtn2.backgroundColor = [UIColor lightGrayColor];
    [testBtn2 setTitle:@"OCBtn" forState:UIControlStateNormal];
    [testBtn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [testBtn2 addTarget:self action:@selector(testAction2) forControlEvents:UIControlEventTouchUpInside];
    testBtn2.layer.borderWidth = 1.0;
    testBtn2.layer.cornerRadius = 3.0;
    [self.view addSubview:testBtn2];
    
    //    _aboutusSwiftBtn = [[UIButton alloc]initWithFrame:CGRectMake(230, UISCREEN_HEIGHT - 50, 100, 30)];
    //    _aboutusSwiftBtn.backgroundColor = [UIColor greenColor];
    //    [_aboutusSwiftBtn setTitle:@"SwiftBtn" forState:UIControlStateNormal];
    //    [_aboutusSwiftBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //    [_aboutusSwiftBtn addTarget:self action:@selector(aboutusSwiftAction) forControlEvents:UIControlEventTouchUpInside];
    //    _aboutusSwiftBtn.layer.borderWidth = 1.0;
    //    _aboutusSwiftBtn.layer.cornerRadius = 3.0;
    //    [self.view addSubview:_aboutusSwiftBtn];
    
    UIButton *testvcBtn = [[UIButton alloc]initWithFrame:CGRectMake(UISCREEN_WIDTH - 120, UISCREEN_HEIGHT - 50, 100, 30)];
    testvcBtn.backgroundColor = [UIColor greenColor];
    [testvcBtn setTitle:@"testvcBtn" forState:UIControlStateNormal];
    [testvcBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [testvcBtn addTarget:self action:@selector(testAction3) forControlEvents:UIControlEventTouchUpInside];
    testvcBtn.layer.borderWidth = 1.0;
    testvcBtn.layer.cornerRadius = 3.0;
    [self.view addSubview:testvcBtn];
}

-(void)cuturl{
    NSString *apiurl = @"http://youngplus.com.hk/app-get-schedule/?client=17189942025&start=2019-4-12&end=2019-4-12&test=1";
    NSLog(@"apiurl: %@", apiurl);
    //3.分隔字符串
    NSArray *array2 = [apiurl componentsSeparatedByString:@"?"]; //从字符A中分隔成2个元素的数组
    NSLog(@"array:%@",array2); //结果是adfsfsfs和dfsdf
    
    NSString *schedule = [array2 objectAtIndex:1];
    NSArray *schedulear = [schedule componentsSeparatedByString:@"&"]; //从字符A中分隔成2个元素的数组
    NSLog(@"schedulear:%@",schedulear); //结果是adfsfsfs和dfsdf
    
    NSString *client = [schedulear objectAtIndex:0];
    NSArray *clientarray = [client componentsSeparatedByString:@"="]; //从字符A中分隔成2个元素的数组
    NSLog(@"clientarray:%@",clientarray); //结果是adfsfsfs和dfsdf
    
    NSString *startstr = [schedulear objectAtIndex:1];
    NSArray *startarray = [startstr componentsSeparatedByString:@"="]; //从字符A中分隔成2个元素的数组
    NSLog(@"startarray:%@",startarray);
    
    NSString *endstr = [schedulear objectAtIndex:2];
    NSArray *endarray = [endstr componentsSeparatedByString:@"="]; //从字符A中分隔成2个元素的数组
    NSLog(@"endarray:%@",endarray);
    
    NSMutableDictionary *scheduleparams = [[NSMutableDictionary alloc]init];
    
    [scheduleparams setValue:[array2 objectAtIndex:0] forKeyPath:@"gourl"];
    [scheduleparams setValue:[clientarray objectAtIndex:0] forKeyPath:@"client1"];
    [scheduleparams setValue:[clientarray objectAtIndex:1] forKeyPath:@"client2"];
    
    [scheduleparams setValue:[startarray objectAtIndex:0] forKeyPath:@"start1"];
    [scheduleparams setValue:[startarray objectAtIndex:1] forKeyPath:@"start2"];
    
    [scheduleparams setValue:[endarray objectAtIndex:0] forKeyPath:@"end1"];
    [scheduleparams setValue:[endarray objectAtIndex:1] forKeyPath:@"end2"];
    
    NSLog(@"scheduleparams:%@",scheduleparams);
    
    network *getnet = [[network alloc]init];
    [getnet POSTrequest:YOUNGURL type:@"getSchedule" senddic:scheduleparams savekey:@"getSchedule"];
}

-(void)testAction1{
    NSLog(@"click testAction1");
//    if (testVC1 == nil) {
//        testVC1 = [[promotionTVCtest alloc]init]; //MenutbVC
//    }
   //notitestVC *test1 =  [[notitestVC alloc]init]; //MenutbVC
    notitestVC2 *test1 =  [[notitestVC2 alloc]init]; 
    //    [self presentViewController:vc_citySelect animated:true completion:nil];
    [self.navigationController pushViewController:test1 animated:true];
}

-(void)testAction2{
    NSLog(@"testAction2");
//        if (testVC2 == nil) {
//            testVC2 = [[registerVC alloc]init];
//        }
    //    [self presentViewController:vc_aboutUsOC animated:true completion:nil];
    
    // Swift文件
    //    ChildViewController *vc = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
    //    [self.navigationController pushViewController:vc animated:YES];
    //    ForthViewController *forthViewVC = [[ForthViewController alloc]init];
    //    [self presentViewController:forthViewVC animated:YES completion:nil];
    
    
//    aboutUsSwiftVC *vc_aboutUSswift = [[aboutUsSwiftVC alloc]init];
//    //[self presentViewController:vc_aboutUSswift animated:YES completion:nil];  //推一个子视图覆盖
   //[self.navigationController pushViewController:testVC2 animated:YES];   //同一个navigationController。推出子视图
    
    //SB 获取viewc
//    UIStoryboard * sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];  //获取SB
////    UIViewController * lvc =
////    [sb instantiateViewControllerWithIdentifier:@"ViewController"];
//
//    registerVC *testVC211 = [sb instantiateViewControllerWithIdentifier:@"registerVC"];  //获取SB 上VC id
//    [self.navigationController pushViewController:testVC211 animated:YES];   //同一个navigationController。推出子视图

    
    FileUploadImage *test2 =  [[FileUploadImage alloc]init];
//    TestclipperVC *test2 =  [[TestclipperVC alloc]init];
    [self.navigationController pushViewController:test2 animated:true];
}

-(void)testAction3{
    
    NSLog(@"click testVCBtn");
    
    CMPedometerVC *cvc = [[CMPedometerVC alloc]init];
    
   
    //LoginViewController2  *LoginVC2 = [[LoginViewController2 alloc]init];
 
    //[self presentViewController:testvc animated:YES completion:nil];  //推一个子视图覆盖
    [self.navigationController pushViewController:cvc animated:YES];   //同一个navigationController。推出子视图
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
